﻿using DevExpress.XtraGrid.Demos.util;
using DXApplicationTangche.UC.下单MTO.Service;
using DXApplicationTangche.UC.抖音出入库.Service;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.抖音出入库
{
    public partial class Form抖音填写需求数量 : DevExpress.XtraEditors.XtraForm
    {
        private DouyinRequestDTO douyinRequestDTO { get; set; }
        private DouyinOrderRequestDTO douyinOrderRequestDTO { get; set; }
        private String type { get; set; }
        public Form抖音填写需求数量(DouyinRequestDTO douyinRequestDTO)
        {
            InitializeComponent();
            this.douyinRequestDTO = douyinRequestDTO;
        }
        public Form抖音填写需求数量(DouyinRequestDTO douyinRequestDTO,String type)
        {
            InitializeComponent();
            this.douyinRequestDTO = douyinRequestDTO;
            this.type = type;
            this.textBox售价.Text = this.douyinRequestDTO.price.ToString();
            this.textBox需求数量.Text = this.douyinRequestDTO.requestQuantity.ToString();
        }
        public Form抖音填写需求数量(DouyinOrderRequestDTO douyinOrderRequestDTO,String type)
        {
            InitializeComponent();
            this.douyinOrderRequestDTO = douyinOrderRequestDTO;
            this.type = type;
        }

        private void simpleButton确认_Click(object sender, EventArgs e)
        {
            
            if (String.IsNullOrEmpty(this.textBox售价.Text)|| String.IsNullOrEmpty(this.textBox需求数量.Text))
            {
                MessageBox.Show("请补充数量及价格信息");
                return;
            }
            try
            {
                this.douyinRequestDTO.build(Convert.ToInt32(this.textBox需求数量.Text.ToString()), double.Parse(this.textBox售价.Text.ToString()));
            }
            catch { }
            this.Close();
        }

        private void textBox需求数量_Validating(object sender, CancelEventArgs e)
        {
            if (!FunctionHelper.Is大于0(this.textBox需求数量.Text.Trim()))
            {
                MessageBox.Show("需求数量必须大于0！");
                this.ActiveControl = this.textBox需求数量;
                return;
            }
        }

        private void textBox售价_Validating(object sender, CancelEventArgs e)
        {
            if (!FunctionHelper.Is大于0(this.textBox售价.Text.Trim()))
            {
                MessageBox.Show("售价必须大于0！");
                this.ActiveControl = this.textBox售价;
                return;
            }
        }
    }
}
